# -*- coding: utf-8 -*-


import array

"""
列表可以存储不同类型元素数据
数组必须存储相同类型元素数据
"""

print(array.typecodes)
# 'bBuhHiIlLqQfd'

"""
b   int     signed char
B   int     unsigned char
u   unicode
h   int     signed short
H   int     unsigned short
i   int     signed int
I   int     unsigned int
l   int     signed long
L   int     unsigned long
q   int     signed long long
Q   int     unsigned long long
f   float   float
d   float   double
"""

if __name__ == '__main__':
    # 定义数组
    # a = array.array(typecode, [initializer])
    a = array.array('i', [1, 2, 3, 4])
    # a = array.array('i', range(4))

    print(a.typecode)
    print(a.itemsize)

    print(a.buffer_info())
    # 元组(地址, 长度)

    # a.fromlist(l)
    # l = a.tolist()

    a1 = array.array('i', [1, 2, 3, 4])
    a.extend(a1)

    x = 0
    a.append(x)

    i = a.index(x)
    a.insert(i, x)
    x = a.pop(i)
    a.remove(x)
    print(a)

    # 统计总数
    print(a.count(x))

    # 数组反转
    a.reverse()
    print(a)

    pass
